<?php
header('Content-Type: application/json');
$imageDir = __DIR__.'/image/';
$allowedExtensions = ['jpg', 'jpeg', 'png', 'gif'];

$images = [];
foreach (scandir($imageDir) as $file) {
    $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
    if (in_array($ext, $allowedExtensions)) {
        $images[] = $file;
    }
}

echo json_encode(array_unique($images)); // 自动去重
?>